package com.ruoyi.system.service.impl;

import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.MessageInfo;
import com.ruoyi.system.mapper.MessageInfoMapper;
import com.ruoyi.system.service.IMessageInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 消息Service业务层处理
 * 
 * @author 杨杰
 * @date 2024-03-04
 */
@Service
public class MessageInfoServiceImpl implements IMessageInfoService 
{
    @Autowired
    private MessageInfoMapper messageInfoMapper;

    /**
     * 查询消息
     * 
     * @param id 消息主键
     * @return 消息
     */
    @Override
    public MessageInfo selectMessageInfoById(Long id)
    {
        return messageInfoMapper.selectMessageInfoById(id);
    }

    /**
     * 查询消息列表
     * 
     * @param messageInfo 消息
     * @return 消息
     */
    @Override
    public List<MessageInfo> selectMessageInfoList(MessageInfo messageInfo)
    {
        return messageInfoMapper.selectMessageInfoList(messageInfo);
    }

    /**
     * 新增消息
     * 
     * @param messageInfo 消息
     * @return 结果
     */
    @Override
    public int insertMessageInfo(MessageInfo messageInfo)
    {
        messageInfo.setCreateTime(DateUtils.getNowDate());
        return messageInfoMapper.insertMessageInfo(messageInfo);
    }

    /**
     * 修改消息
     * 
     * @param messageInfo 消息
     * @return 结果
     */
    @Override
    public int updateMessageInfo(MessageInfo messageInfo)
    {
        messageInfo.setUpdateTime(DateUtils.getNowDate());
        return messageInfoMapper.updateMessageInfo(messageInfo);
    }

    /**
     * 批量删除消息
     * 
     * @param ids 需要删除的消息主键
     * @return 结果
     */
    @Override
    public int deleteMessageInfoByIds(String ids)
    {
        return messageInfoMapper.deleteMessageInfoByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除消息信息
     * 
     * @param id 消息主键
     * @return 结果
     */
    @Override
    public int deleteMessageInfoById(Long id)
    {
        return messageInfoMapper.deleteMessageInfoById(id);
    }
}
